import { createStore } from 'vuex';
import getters from './getters';
/*获取使用webpack方法获取所有模块*/
const modulesFiles = require.context('./modules',true,/\.ts$/);

/*遍历所有模块累加为一个模块对象*/
const modules = modulesFiles.keys().reduce((modules:any, modulePath:any) => {
  const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
  const value = modulesFiles(modulePath)
  modules[moduleName] = value.default
  return modules
},{})

export default createStore({
  modules,
  getters
}) as any
